from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType

from main.models import Client


def post_migrate_callback(sender, **kwargs):
    admin_group, created = Group.objects.get_or_create(name="Admins")
    # # Now what - Say I want to add 'Can add project' permission to new_group?
    # permission = Permission.objects.create(
    #     codename='can_add_project',
    #     name='Can add project',
    #     content_type=ct
    # )
    # new_group.permissions.add(permission)
    admin_group.permissions.add(
        *Permission.objects.filter(
            content_type=ContentType.objects.get_for_model(Client)
        )
    )
